import java.net.UnknownHostException;
import java.util.List;

import com.mongodb.Mongo;
import com.mongodb.DB;
import com.mongodb.DBCollection;
import com.mongodb.BasicDBObject;
import com.mongodb.DBObject;
import com.mongodb.DBCursor;
import com.mongodb.QueryBuilder;

//import com.mongodb.MongoException;


public class GoogleCluster{
	
	public static DBCollection job_events;
	public static DBCollection machine_events;
	public static List<DBObject> listJobEvents;
	
	public static void main(String[] args) throws UnknownHostException
	{
		//dataIO newIO = new dataIO();

		//newIO.listDirectory();
		
		Mongo m = accessDB.connect();
		DBCursor IDcursor;
		
		if(m == null)
			return;
		
		job_events = accessDB.getCollection("job_events");
		
		BasicDBObject IDquery = new BasicDBObject();
		BasicDBObject keys = new BasicDBObject();
		
		IDquery.put("event_type", "1");
		keys.put("job_id", 1);
		keys.put("event_type", 1);
		keys.put("time", 1);
		
		BasicDBObject sortBy = new BasicDBObject();
		sortBy.put("time", 1);
		IDcursor = job_events.find(IDquery, keys).skip(3983).sort(sortBy);
		
		SimulateJobs s = new SimulateJobs (IDcursor, job_events, 20);
		s.reset ();
		s.makeFrame();
		
		
		/*
		BasicDBObject endQuery = (BasicDBObject) QueryBuilder.start().or(new BasicDBObject("event_type", "3"), new BasicDBObject("event_type", "5"), new BasicDBObject("event_type", "6")).get();		
		endQuery.put("job_id", "986962601");
		DBCursor endTimeCursor = job_events.find(endQuery, keys);
		
		endTimeCursor.next();
		
		System.out.println(endTimeCursor.curr().toString());
		*/
	}
}
